import { ref, watch } from 'vue';
import { deptList } from '@/api/system/dept';
import { arrayToTree } from '@/utils';

export function useDeptData() {
  const deptData = ref([]);
  const getDeptData = async () => {
    let res = await deptList();
    if (!res.data) return;
    deptData.value = arrayToTree(res.data, 0);
  };
  return {
    deptData,
    getDeptData,
  };
}
